package com.example.myapplication1;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class ScoringActivity extends AppCompatActivity {

    private int scoreTeamA = 0;
    private int scoreTeamB = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scoring);
    }
    public void addScoreTeamA(View view) {
        if (view.getId() == R.id.team_a_3_points) {
            scoreTeamA += 3;
        } else if (view.getId() == R.id.team_a_2_points) {
            scoreTeamA += 2;
        } else if (view.getId() == R.id.team_a_free_throw) {
            scoreTeamA += 1;
        }
        displayScoreTeamA(scoreTeamA);
    }
    public void addScoreTeamB(View view) {
        if (view.getId() == R.id.team_b_3_points) {
            scoreTeamB += 3;
        } else if (view.getId() == R.id.team_b_2_points) {
            scoreTeamB += 2;
            scoreTeamB += 1;        } else if (view.getId() == R.id.team_b_free_throw) {

        }
        displayScoreTeamB(scoreTeamB);
    }

    public void resetScore(View view) {
        scoreTeamA = 0;
        scoreTeamB = 0;
        displayScoreTeamA(scoreTeamA);
        displayScoreTeamB(scoreTeamB);
    }

    private void displayScoreTeamA(int score) {
        TextView scoreView = findViewById(R.id.team_a_score);
        scoreView.setText(String.valueOf(score));
    }

    private void displayScoreTeamB(int score) {
        TextView scoreView = findViewById(R.id.team_b_score);
        scoreView.setText(String.valueOf(score));
    }
}
